<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>执行高空风险</title>
    <meta
      name="viewport"
      content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"
    />
    <link href="../../../css/mui.min.css" rel="stylesheet" />
    <link href="../css/common.css" rel="stylesheet" />
    <link rel="stylesheet" type="text/css" href="../../../css/preview.css" />
    <style>
      /* .mui-content>.mui-table-view:first-child {
          margin-top: 1px;
      } */
      /* .icon{
        width: 35px;
        vertical-align: middle;
        margin-right: 10px;
      } */
      /* .mui-table-view-cell:after {
          left: 45px;
          height: 1px;
      } */
      /* .mui-table-view-cell{
        padding: 11px 11px 11px 11px;
      } */
      /* .mui-table-view:after {
          left: 45px;
      } */
      /* .mui-bar{
		  background-color: #0082E6;
	  } */
      .uls {
        padding: 20px 20px;
        list-style: none;
        margin: 0;
      }

      .mui-table-view:after {
        height: 0;
      }
      .titles {
        /* font-weight: bold; */
        margin-bottom: 24px;
      }

      .img_s {
        float: left;
        width: 20px;
        height: 20px;
        line-height: 20px;
        text-align: center;
        color: #fff;
        background-color: #0082e6;
        border-radius: 100%;
        /* background: url(../img/word.png) no-repeat; */
        /* background-size: 100%; */
        margin: auto 0;
      }
      .bocks {
        padding: 0 5px;
      }
      .areas {
        background-color: #f5f6f7;
        border: solid 1px #dcdcdc;
      }
      .imgss {
        float: left;
        margin-right: 10px;
      }
      .imgss img {
        width: 100%;
      }
      .signs {
        display: inline-block;
        width: 160px;
        height: 160px;
        border: solid 1px #3188fe;
        border-radius: 5px;
        margin-right: 10px;
        margin-bottom: 10px;
        position: relative;
        overflow: hidden;
        /* background-color: #D4E6FF; */
      }
      .uploads {
        display: inline-block;
        width: 160px;
        height: 160px;
        /* border-radius: 5px; */
        background: url(../img/task/dianjipaizhao.png) no-repeat;
        background-size: 100%;
        margin-bottom: 20px;
      }

      .submits {
        width: 100%;
        margin-top: 30px;
        height: 4 0px;
        border-radius: 30px;
      }
      .fixed-btn .mui-btn {
        width: 30%;
      }
      .putList {
        display: flex;
        justify-content: space-between;
        padding-bottom: 20px;
      }
      .putList input {
        width: 80%;
      }
      .sx_s {
        color: #fff;
      }
      .sx_s span {
        font-size: 17px;
      }
      .screens {
        position: absolute;
        top: 44px;
        left: 0;
        width: 100%;
        min-height: 200px;
        background-color: #fff;
        z-index: 999;
      }
      .content_ul {
        padding: 30px;
        overflow: hidden;
      }
      .content_ul .rowli ul {
        padding: 0;
        margin: 0;
        list-style: none;
        border-bottom: solid 1px #dcdcdc;
        overflow: hidden;
        display: flex;
        flex-wrap: wrap;
        /* justify-content: space-between; */
      }
      .rowli ul li {
        width: 30px;
        height: 30px;
        text-align: center;
        line-height: 30px;
        background-color: #f5f6f7;
        border: solid 1px #c2cfda;
        border-radius: 3px;
        color: #000;
        /* float: left; */
        margin-right: 20px;
        margin-bottom: 20px;
        box-sizing: border-box;
        /* flex-grow: 1; */
      }
      .rowli ul li.ls {
        background-color: #3188fe;
        color: #fff;
      }
      .btnli {
        text-align: center;
        padding-top: 30px;
        /* display: flex;
        justify-content: space-between; */
      }
      .btnli .btns {
        background-color: #e7ecf1;
      }
      .btnli button {
        width: 45%;
      }
      .signs .action-delete {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        text-align: center;
      }
      .action-delete .mui-icon {
        color: #ffffff;
      }
      .btn-active {
        border-style: dashed !important;
      }
      .radios .rs1 {
        left: 100px;
      }
      
      .radios .rs2 {
        left: 180px;
      }
      .oks {
        position: absolute;
        left: 130px;
        top: 10px;
      }
      
      .nos {
        position: absolute;
        left: 210px;
        top: 10px;
      }
    </style>
  </head>
  <body>
    <div id="container">
      <header class="mui-bar mui-bar-nav">
        <a
          class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left text-white"
        ></a>
        <h1 class="mui-title">执行高空风险</h1>
        <a class="mui-pull-right mui-bar-right" @click="getSearch">
          <img src="../img/screen.png" width="18" style="margin-right: 3px;" />
          <span> 筛选</span>
        </a>
        <!-- <a
          class="mui-icon mui-icon-right-nav mui-pull-right mui-icon mui-icon-gear sx_s"
          @click="getSearch"
          ><span>筛选</span></a
        > -->
      </header>
      <div class="mui-content page-wrap" v-cloak>
        <ul class="uls page-scroll">
          <li class="lis" style="margin-bottom: 20px" v-cloak>
            <div>
              {{idxs + 1}}、{{currentIndex + 1}}/{{allWp.length}}
              {{detail.position ? '辅助工序': '基本工序'}}
            </div>
            <div><span>工序编号：</span><span>{{detail.wpCode}}</span></div>
            <div><span>作业项目：</span><span>{{detail.jobProject}}</span></div>
            <div><span>作业方法：</span><span>{{detail.jobMethod}}</span></div>
          </li>
          <li
            class="lis"
            v-for="(item,index) in projectList"
            :key="index"
            v-cloak
          >
            <!-- <img src="./img/xiaoxitongzhi_icon1.png" class="icon"> -->
            <div class="titles">
              <span class="img_s">{{index+1}}</span>
              <span class="bocks"
                >{{item.refInput.name}}
                {{item.refInput.explain}}：{{inputShowText(item.refInput,
                dict)}}</span
              >
            </div>
            <div class="putList" v-if="item.refInput.typeValue == 'number'">
              <div>
                <input
                  type="number"
                  v-model="item.value"
                  class="val1"
                  maxlength="20"
                />
              </div>
            </div>
            <div v-if="item.refInput.typeValue == 'text'">
              <textarea
                type="text"
                v-model="item.remarks"
                class="areas"
                maxlength="200"
              ></textarea>
            </div>
            <div class="upsign" v-if="item.refInput.typeValue == 'img'">
              <div v-if="item.files" class="imgss">
                <span class="signs" v-for="(v,i) in item.files" v-cloak>
                  <img
                    :src="v.path|| (baseUrl + v.filePath)"
                    :data-preview-src="v.path|| (baseUrl + v.filePath)"
                    :data-preview-group="index"
                  />
                  <div class="action-delete" @tap="deleteImg(v,index, i)">
                    <span class="mui-icon mui-icon-trash"></span>
                  </div>
                </span>
              </div>
              <span class="uploads" id="headImage" @tap="addPic(index)"></span>
            </div>
            <div v-if="item.refInput.typeValue == 'boolean'">
              <div class="mui-input-row mui-radio radios">
                 <label>选项(是否)：</label>
                 <input :name="'radio' + index + 1" v-model="item.value" :checked="item.value=='是'?true:false" type="radio" value="是" class="rs1">
                 <span class="oks">是</span>
                 <input :name="'radio' + index + 1" v-model="item.value" :checked="item.value=='是'?false:true" type="radio" value="否" class="rs2">
                 <span class="nos">否</span>
               </div> 
            </div>
          </li>
        </ul>
        <div class="fixed-btn">
          <button
            type="button"
            @tap="upInfo()"
            class="mui-btn mui-btn-outlined"
            v-if="idxs>0 || currentIndex> 0"
          >
            上一个
          </button>
          <!--占位-->
          <span v-else></span>
          <button
            type="button"
            @tap="nextInfo()"
            class="mui-btn mui-btn-outlined"
            v-if="idxs<aList.length-1 || currentIndex < allWp.length - 1"
          >
            下一个
          </button>
          <button
            type="button"
            @tap="saveInfo(false)"
            class="mui-btn mui-btn-primary"
            v-else
          >
            保存
          </button>
        </div>
        <div class="screens mui-popover mui-popover-top">
          <div
            class="head_s mui-segmented-control mui-segmented-control-inverted mui-segmented-control-primary"
            style="background-color: #fff"
          >
            <a class="mui-control-item mui-active" href="#items1"
              ><span class="txt">全部</span></a
            >
            <a class="mui-control-item" href="#items2"
              ><span class="txt">已完成</span></a
            >
            <a class="mui-control-item" href="#items3"
              ><span class="txt">未完成</span></a
            >
          </div>
          <div class="content_ul">
            <div
              class="rowli mui-slider-item mui-control-content mui-active"
              id="items1"
            >
              <ul v-if="aList.length>0">
                <li
                  v-for="(v,index) in aList"
                  :key="v.id"
                  @tap="nextInfo(v.id,v.index)"
                  v-cloak
                >
                  {{v.index+1}}
                </li>
              </ul>
            </div>
            <div class="rowli mui-slider-item mui-control-content" id="items2">
              <ul v-if="yList.length>0">
                <li
                  v-for="(v,index) in yList"
                  :key="v.id"
                  @tap="nextInfo(v.id,v.index)"
                  v-cloak
                >
                  {{v.index+1}}
                </li>
              </ul>
            </div>
            <div class="rowli mui-slider-item mui-control-content" id="items3">
              <ul v-if="wList.length>0">
                <li
                  v-for="(v,index) in wList"
                  :key="v.id"
                  @tap="nextInfo(v.id,v.index)"
                >
                  {{v.index+1}}
                </li>
              </ul>
            </div>
            <div class="btnli">
              <button type="button" class="mui-btn btns" @tap="getSearch()">
                关闭
              </button>
              <!--<button type="button" class="mui-btn mui-btn-primary" @tap="endSearch()">确认</button>-->
            </div>
          </div>
        </div>
      </div>
    </div>
    <script src="../../../js/mui.js"></script>
    <script src="../../../js/mui.pullToRefresh.js"></script>
    <script src="../../../js/mui.pullToRefresh.material.js"></script>
    <script src="../../../js/jquery-1.7.2.min.js"></script>
    <script src="../../../js/vue.js"></script>
    <script src="../js/main.js"></script>
    <script src="../js/mkeyplus.base.js"></script>
    <script src="../js/uploadImage.js"></script>
    <script
      src="../js/sqlite.js"
      type="text/javascript"
      charset="utf-8"
    ></script>
    <script src="../../../js/mui.zoom.js"></script>
    <script
      src="../../../js/mui.previewimage.js"
      type="text/javascript"
      charset="utf-8"
    ></script>
    <script src="../js/indexDBs.js"></script>
    <script type="text/javascript">
      mui.init()
      mui.previewImage()
      var ids = 1;
      var idxs = 0;
      var dict = {};
      var self = null;
      var dbId = 0;
      let lineType =null;
      let db={};
      const dbName = 'myDBs'; // 数据库的名字
      const storeName = 'listPackage'; //仓库名称
      let lineDetails = {};
      // var dict=dict
      if (window.plus) {
        plusready()
      } else {
        document.addEventListener("plusready", plusready, false)
      }

     async function plusready() {
        self = plus.webview.currentWebview()
        console.log("idssss", self)
        // vm.form.projectTaskId = self.projectTaskId
        // vm.form.projectCategory = self.projectCategory
        ids = self.projectTaskId;
        idxs = self.idxs;
        dbId = self.dbId;
        vm.idxs = self.idxs;
        vm.aList = self.aList;
        lineType = getSysInfo();
        vm.lineType = getSysInfo();
        await openDB(dbName, storeName, 1).then(res=>{
          console.log('openDB',res)
          db = res
        })
        mui.baseApp
          .getDict(["valueUnit", "valueType", "inputSymbol", "wpTag"])
          .then((res) => {
            console.log("-------------")
            console.log(res)
            vm.dict = res
            dict = res
            vm.wpTagList = res.wpTag
        })
		
        // 是否离线
        if(!lineType){
        	getLineData()
        	// getCacheData()
        } else {
        	// 有网有离线数据
        	getDataByKey(db, storeName,dbId).then(res=>{
        		console.log('是否有离线数据',res)
        		if(res == undefined){
        			getProject(ids)
        			vm.getLists()
        			vm.isOnlineAndOfflineData = false
        		} else {
        			getLineData()
        			vm.lineType = lineType = false
        			vm.isOnlineAndOfflineData = true
        		}
        	})
        }
        
      }
      var vm = new Vue({
        el: "#container",
        dicts: ["valueUnit", "valueType", "inputSymbol"],
        data: {
		  isOnlineAndOfflineData: false,
          projectList: [],
          dict: dict,
          aList: [],
          yList: [],
          wList: [],
          allList: [],
          wpTagList: [],
          idxs: 0,
          baseUrl: mui.baseApp.serverUrl,
          detail: {},
          allWp: [], //当前基本工序加辅助工序
          currentIndex: 0, //当前基本工序加辅助工序所在索引
          lxDatas:{},
          listDatas:{},
          lineDetails:{},
          lineType:null,
        },
        computed: {
          headers() {
            return function (item, i) {
              return item.value ? item.value.split(",")[i] : ""
            }
          },
        },
        created: function () {
          //           getProject(ids)
          //           this.getLists()
        },
        methods: {
          validate(num, type) {
			  //num 是否自动保存
			  if(this.detail.isReturn) { //工序已退回
				return false
			  }
			  let isFill = false //是否存在填写项
			  let isNoFill = false //是否存在未填写项
			  this.projectList.forEach(res => {
				if(res.refInput.typeValue == 'number' || res.refInput.typeValue == 'boolean') {
				   if(res.value || res.value === 0) {
					 isFill = true
				   } else {
					 isNoFill = true
				   }
				 }
				 if(res.refInput.typeValue == 'text') {
				   if(res.remarks) {
					 isFill = true
				   } else {
					 isNoFill = true
				   }
				   
				 }
				 if(res.refInput.typeValue == 'img') {
				   if(Array.isArray(res.files) && res.files.length) {
					 isFill = true
				   } else {
					 isNoFill = true
				   }
				   
				 }
			  })
			  if(this.projectList.length === 0) { //没有输入值 默认已输入
				isFill = true
			  }
			  if((isFill && isNoFill) || (!num && isNoFill)) { //同时存在输入项和未输入项   或 手动保存存在未输入项
				mui.toast('请完善输入值信息')
				return false
			  }
			  if(this.fileimg) {
				if(!this.anomalyInfo.remarks) {
				  mui.toast('请填写异常信息')
				  return false
				}
	//            if(!this.anomalyInfo.files.length) {
	//              mui.toast('请上传异常图片')
	//              return false
	//            }
			  }
			  if(this.detail.tagId) {
				// 填了或选择了异常
				// if((!num || isFill || this.fileimg) && !this.signInfo.takeImg.filePath) {
				if(!this.signInfo.takeImg.filePath) {
				  mui.toast('请上传负责人拍照信息')
				  return false
				}
				// if((!num || isFill || this.fileimg) && !this.signInfo.signImg.filePath) {
				if(!this.signInfo.signImg.filePath) {
				  mui.toast('请负责人签字')
				  return false
				}
				
			  }
			  if(num && !isFill && type == 'save') {
				return false
			  }
			  return true
			},
          saveInfo(num) {
            let then = this
            console.log("编辑数据", this.projectList)
			
            return new Promise((resolve, reject) => {
			  
              if(!this.validate(num, 'save')) {
                resolve()
                // return
              }
			  
              let parm = {
                projectId: self.projectId,
                projectTaskSensitiveId: ids,
                stage: 3,
                inputs: this.projectList,
              }
              let ajaxName = "sensitive"
              console.log("+++++++++++++")
              console.log(this.detail)
              if (this.detail.position) {
                //辅助工序
                parm.projectTaskSubSensitiveId =
                  vm.allWp[vm.currentIndex].projectTaskSubSensitiveId
                ajaxName = "subSensitive"
              } else {
                parm.projectTaskSensitiveId = ids;
              }
              console.log(parm)
              //辅助工序详情的切换不走接口  保存提交时参数
              Object.assign(vm.allWp[vm.currentIndex], parm);
              plus.nativeUI.showWaiting("保存中...")
              if(!lineType || vm.isOnlineAndOfflineData){
                // 获取离线数据
                // getLineData()
                mui.confirm('当前是离线数据，是否需要保存编辑内容？','提示',['是','否'],function(item){
                  console.log('对话框提示',item)
                  if(item.index==0){
                    if(then.detail.position) {
                      lineDetails.subWps.forEach((item,i)=>{
                        if(item.projectTaskSubSensitiveId==then.detail.projectTaskSubSensitiveId){
                          lineDetails.subWps[i]=Object.assign(item,parm)
                          lineDetails.subWps[i].status=4
                          then.$set(lineDetails.subWps,i,Object.assign(item,parm))
                        }
                      })
                    }else{
                      lineDetails= Object.assign(lineDetails,parm)
                      then.listDatas.status=4
                      lineDetails.status=4
                    }
                    // lineDetails= Object.assign(lineDetails,parm)
                    console.log('编辑数据22000', JSON.stringify(then.lxDatas))
                    getUpdata(then.lxDatas,num)
                    resolve(parm)
                  }else{
                    // getDel(taskId)
                  }
                })
                 return
              } else {
				// 删除提交参数path
				parm.inputs.forEach((a,i)=>{
					a.files === null ? [] :
					a.files.forEach((b,i)=>{
						delete a.files[i].path;  
					})
				})
				if(parm.signInfo !== undefined){
					delete parm.signInfo.takeImg.path
				}
				mui.baseApp.httpRequst("post", "/app/api/project/execution/" + ajaxName + "/execution", parm, function (data) {
				    console.log("数据列表", data)
				    plus.nativeUI.closeWaiting()
				    mui.toast("保存成功")
				    mui.fire(self.opener(), "back", {})
				    let listPage = plus.webview.getWebviewById("./riskList.html")
				    let detailPage = plus.webview.getWebviewById("./carryoutToDoDetail.html")
				    if (listPage) {
				      mui.fire(listPage, "back", {})
				    }
				    if (detailPage) {
				      mui.fire(detailPage, "back", {})
				    }
				    if (!num) {
				      mui.back()
				    }
				    resolve(parm)
				  },
				  function () {
				    plus.nativeUI.closeWaiting()
				    // mui.toast("保存失败")
				    console.log("获取数据失败")
				    reject()
				  })
			  }
              
            })

            // return false
          },
          upInfo() {
            if (!this.validate(true)) {
              return
            }
            this.saveInfo(true).then(res => {
              let noId = false
              if (res && res.inputs) {
                res.inputs.forEach((item) => {
                  if (!item.id) {
                    noId = true
                  }
                })
              }
              this.upFun(noId)
            })
          },
          upFun(noId) {
            vm.lineType = getSysInfo();
            lineType = getSysInfo();
            if (vm.currentIndex > 0) {
              vm.currentIndex--
              handleData({
                data: vm.allWp[vm.currentIndex],
              })
              if (noId) {
                if(!lineType){
                  getLineData("cancel")
                  return
                }
                //没有ID保存完重新请求接口
                getProject(ids, "cancel")
              }
              return
            }
            if (this.aList.length >= 1 && this.idxs > 0) {
              //              this.saveInfo(true)
              this.idxs--
              ids = this.aList[this.idxs]["id"]
              if(!lineType){
                getLineData()
                return
              }
              getProject(ids)
            } else {
              mui.toast("没有了")
            }
          },
          nextInfo(vid, index) {
            if (!this.validate(true)) {
              return
            }
			
            this.saveInfo(true).then(res => {
              let noId = false
              if (res && res.inputs) {
                res.inputs.forEach((item) => {
                  if (!item.id) {
                    noId = true
                  }
                })
              }
              this.nextFun(vid, index, noId)
            })

            // getProject(ids)
          },
          nextFun(vid, index, noId) {
            vm.lineType = getSysInfo();
            lineType = getSysInfo();
            if (vid) {
              //              this.saveInfo(true)
              this.idxs = index
              ids = vid
              if(!lineType){
                getLineData()
                mui(".screens").popover("toggle")
                return
              }
              getProject(ids)
              mui(".screens").popover("toggle")
            } else {
              if (vm.currentIndex + 1 < vm.allWp.length) {
                vm.currentIndex++
                handleData({
                  data: vm.allWp[vm.currentIndex],
                })
                console.log(noId)
                if (noId) {
                  if(!lineType){
                    getLineData("cancel")
                    return
                  }
                  getProject(ids, "cancel")
                }
                return
              }
              if (this.aList.length > 1 && this.aList.length > this.idxs + 1) {
                //                this.saveInfo(true)
                this.idxs++
                ids = this.aList[this.idxs]["id"]
                if(!lineType){
                  getLineData()
                  return
                }
                getProject(ids)
              } else {
                mui.toast("没有了")
              }
            }
          },
          getLists() {
            vm.yList = []
            vm.wList = []
            this.aList.forEach((res, index) => {
              console.log("idds", res)
              res.index = index
              if (res.status == 4) {
                console.log("idds12", res)
                vm.yList.push(res)
              } else {
                vm.wList.push(res)
              }
            })
          },
          // 添加图片
          addPic(index) {
            var that = this
            vm.lineType = getSysInfo();
            lineType = getSysInfo();
            page.imgUp(function (path) {
              console.log("compress image path: " + path)
              plus.nativeUI.showWaiting("加载中...")
              if(!lineType){
                if (that.projectList[index].files) {
                  that.projectList[index].files.push({
                    path: path,
                    // fileId: res.data.id,
                    filePath: path
                  })
                } else {
                  that.projectList[index].files = [{
                    path: path,
                    // fileId: res.data.id,
                    filePath: path
                  }]
                }
                plus.nativeUI.closeWaiting()
                return
              }
              mui.baseApp.upLoadFile(
                path,
                function (res) {
                  plus.nativeUI.closeWaiting()
                  mui.toast("上传成功")
                  // this.projectList[index].push()
                  // if(index==3){
                  //   that.signInfo.takeImg.fileId = res.data.id
                  //   that.signInfo.takeImg.filePath = res.data.fileDirectory
                  // }else if(index==2){
                  console.log("9999999", this.projectList)
                  if (that.projectList[index].files) {
                    that.projectList[index].files.push({
                      path: path,
                      fileId: res.data.id,
                      filePath: res.data.fileDirectory,
                    })
                  } else {
                    that.projectList[index].files = [
                      {
                        path: path,
                        fileId: res.data.id,
                        filePath: res.data.fileDirectory,
                      },
                    ]
                  }

                  // }
                },
                function () {
                  plus.nativeUI.closeWaiting()
                  console.log("获取数据失败")
                }
              )
            })
          },
          // 删除图片
          deleteImg(item, index, i) {
            var that = this
            mui.confirm(
              "确定要删除此图片吗？",
              "提示",
              ["取消", "确认"],
              function (e) {
                console.log(e.index)
                if (e.index === 1) {
                  // 确认
                  var images = that.projectList[index].files
                  images.splice(i, 1)
                  // that.$set(that.checkDetails[index], 'images', images);
                } else {
                  console.log("取消删除")
                }
              },
              "div"
            )
          },
          getSearch() {
            mui(".screens").popover("toggle")
            // this.searchs=!this.searchs
          },
          endSearch() {
            let h = $(".head_s .mui-active").attr("href")
            if (h == "#items1") {
              this.allList = this.aList
            } else if (h == "#items2") {
              this.allList = this.yList
            } else if (h == "#items3") {
              this.allList = this.wList
            }
            mui(".screens").popover("toggle")
          },
          showValue2(obj, dict) {
            if (!obj.typeSubId) {
              return false
            }
            let types = dict.id.inputSymbol[obj.typeSubId].value // 符号
            let typeSub = ["()", "[]", "(]", "[)", ")(", "][", ")[", "]("]
            return typeSub.includes(types)
          },
          inputShowText(obj, dict) {
            // console.log(obj)
            let type = dict.id.valueType[obj.typeId].value // 类型
            if (type == "text") {
              return obj.value
            } else if (type == "img") {
              return "无"
            } else if (type == 'boolean') {
              return '是否'
            } else {
              let unit = dict.id.valueUnit[obj.unitId].value // 单位
              let symbol = dict.id.inputSymbol[obj.typeSubId].value // 符号
              let valueArr = obj.value.split(",")
              let showText = ""
              switch (symbol) {
                case ">":
                  showText = ">" + valueArr[0] + unit
                  break
                case "≥":
                  showText = "≥" + valueArr[0] + unit
                  break
                case "<":
                  showText = "<" + valueArr[0] + unit
                  break
                case "≤":
                  showText = "≤" + valueArr[0] + unit
                  break
                case "=":
                  showText = "=" + valueArr[0] + unit
                  break
                case "!=":
                  showText = "!=" + valueArr[0] + unit
                  break
                case "()":
                  showText =
                    ">" + valueArr[0] + unit + "  " + "<" + valueArr[1] + unit
                  break
                case "[]":
                  showText =
                    "≥" + valueArr[0] + unit + "  " + "≤" + valueArr[1] + unit
                  break
                case "(]":
                  showText =
                    ">" + valueArr[0] + unit + "  " + "≤" + valueArr[1] + unit
                  break
                case "[)":
                  showText =
                    "≥" + valueArr[0] + unit + "  " + "<" + valueArr[1] + unit
                  break
                case ")(":
                  showText =
                    "<" + valueArr[0] + unit + "  " + ">" + valueArr[1] + unit
                  break
                case "][":
                  showText =
                    "≤" + valueArr[0] + unit + "  " + "≥" + valueArr[1] + unit
                  break
                case ")[":
                  showText =
                    "<" + valueArr[0] + unit + "  " + "≥" + valueArr[1] + unit
                  break
                case "](":
                  showText =
                    "≤" + valueArr[0] + unit + "  " + ">" + valueArr[1] + unit
                  break
                default:
                  showText = obj.value + unit
                  break
              }
              return showText
            }
          },
        },
      })
      // function showValue2(obj,dict) {
      //     let types=dict.id.inputSymbol[obj.typeSubId].value // 符号
      //     let typeSub = ['()', '[]', '(]', '[)', ')(', '][', ')[', '](']
      //     return typeSub.includes(types)
      // }
      function getProject(ids, type) {
        plus.nativeUI.showWaiting("加载中...")
        mui.baseApp.httpRequst(
          "get",
          "/app/api/project/execution/sensitive/detail/" + ids,
          null,
          function (data) {
            console.log("返回工序", data)
            plus.nativeUI.closeWaiting()

            let subWps = data.data.subWps || []
            let prefix = [] // 前置
            let suffix = [] // 后置
            subWps.forEach((item) => {
              item.isReturn = data.data.isReturn
              if (item.position == 1) {
                prefix.push(item)
              } else {
                suffix.push(item)
              }
            })
            delete data.data.subWps
            vm.allWp = prefix.concat([data.data]).concat(suffix)
            if (type != "cancel") {
              // 取消保持原来的
              vm.currentIndex = 0
            }

            handleData({
              data: vm.allWp[vm.currentIndex],
            })
          },
          function () {
            plus.nativeUI.closeWaiting()
            console.log("获取数据失败")
          }
        )
      }
      function getCacheData(){
        getDataByKey(db, storeName,dbId).then(res=>{
          vm.lxDatas=res
          let data={}
          res.wpItemList.forEach(msg=>{
            if(msg.childs&&msg.childs.length>0){
              msg.childs.forEach(item=>{
                if(item.childs&&item.childs.length>0){
                  item.childs.forEach(v=>{
                     console.log('ok3',v)
                    if(v.childs&&v.childs.length>0){
                      console.log('ok4',v.childs)
                    }
                    if(v.taskWps&&v.taskWps.length>0){
                       v.taskWps.forEach(c=>{
                         if(c.id==ids){
                           console.log('ccc',c.details)
                           vm.listDatas=c
                           data=c.details
                         }
                       })
                    }
                  })
                }
                if(item.taskWps&&item.taskWps.length>0){
                   item.taskWps.forEach(b=>{
                     if(b.id==ids){
                       console.log('bbb',b.details)
                       vm.listDatas=b
                       data=b.details
                     }
                   })
                }
              })
            }
            if(msg.taskWps&&msg.taskWps.length>0){
               msg.taskWps.forEach(a=>{
                 if(a.id==ids){
                   console.log('aaa',a.details)
                   vm.listDatas=a
                   data=a.details
                 }
               })
            }
          })
          // vm.lineDetails=data
          lineDetails=data
        })
      }
      //获取离线数据
      function getLineData(type){
        getDataByKey(db, storeName,dbId).then(res=>{
           plus.nativeUI.closeWaiting(); 
          console.log('获取离线数据',res)
          vm.lxDatas=res
          let data={}
          res&&res.sensitiveList&&res.sensitiveList.forEach(msg=>{
            if(msg.childs&&msg.childs.length>0){
              msg.childs.forEach(item=>{
                if(item.childs&&item.childs.length>0){
                  item.childs.forEach(v=>{
                     console.log('ok3',v)
                    if(v.childs&&v.childs.length>0){
                      console.log('ok4',v.childs)
                    }
                    if(v.taskWps&&v.taskWps.length>0){
                       v.taskWps.forEach(c=>{
                         if(c.id==ids){
                           console.log('ccc',c.details)
                           vm.listDatas=c
                           data=c.details
                         }
                       })
                    }
                  })
                }
                if(item.taskWps&&item.taskWps.length>0){
                   item.taskWps.forEach(b=>{
                     if(b.id==ids){
                       console.log('bbb',b.details)
                       vm.listDatas=b
                       data=b.details
                     }
                   })
                }
              })
            }
            if(msg.taskWps&&msg.taskWps.length>0){
               msg.taskWps.forEach(a=>{
                 if(a.id==ids){
                   console.log('aaa',a.details)
                   vm.listDatas=a
                   data=a.details
                 }
               })
            }
          })
          // vm.lineDetails=data
          lineDetails=data
          let datas ={...data}
            let subWps = datas.subWps || []
            let prefix = [] // 前置
            let suffix = [] // 后置
            subWps.forEach((item) => {
              item.isReturn = datas.isReturn
              if (item.position == 1) {
                prefix.push(item)
              } else {
                suffix.push(item)
              }
            })
            delete datas.subWps
            vm.allWp = prefix.concat([datas]).concat(suffix)
            if (type != "cancel") {
              // 取消保持原来的
              vm.currentIndex = 0
            }
            
            handleData({
              data: vm.allWp[vm.currentIndex],
            })
        })
      }
      function getUpdata(lxDatas,num){
         updateDB(db, storeName,lxDatas).then(msg=>{
           console.log('离线保存',JSON.stringify(msg))
           plus.nativeUI.closeWaiting();
           if(msg.isTrusted){
              mui.toast("保存成功")
              mui.fire(self.opener(), "back", {})
              let listPage = plus.webview.getWebviewById("./riskList.html")
              let detailPage = plus.webview.getWebviewById(
                "./carryoutToDoDetail.html"
              )
              if (listPage) {
                mui.fire(listPage, "back", {})
              }
              if (detailPage) {
                mui.fire(detailPage, "back", {})
              }
              if (!num) {
                mui.back()
              }
           }else{
             mui.toast("保存失败")
           }
              
         })
       }
      function handleData(data) {
        data = JSON.parse(JSON.stringify(data))
        vm.projectList = data.data.inputs
        vm.detail = data.data
      }
      function getSysInfo() {
          types = {};
          types[plus.networkinfo.CONNECTION_UNKNOW] = "未知";
          types[plus.networkinfo.CONNECTION_NONE] = "未连接网络";
          types[plus.networkinfo.CONNECTION_ETHERNET] = "有线网络";
          types[plus.networkinfo.CONNECTION_WIFI] = "WiFi网络";
          types[plus.networkinfo.CONNECTION_CELL2G] = "2G蜂窝网络";
          types[plus.networkinfo.CONNECTION_CELL3G] = "3G蜂窝网络";
          types[plus.networkinfo.CONNECTION_CELL4G] = "4G蜂窝网络";
       
          var str = types[plus.networkinfo.getCurrentType()];
          if (str == '未知' || str == '未连接网络') {
              return false;
          } else {
              return true;
          }
       
      }
      $(document).ready(function () {
        let height = document.documentElement.clientHeight
        //防止软键盘弹出底部按钮顶上来
        $(".mui-content").css("height", height + "px")
      })
      $("#sign").click(function () {
        // mui.baseApp.openWindow('../common/sign.html')
      })
    </script>
  </body>
</html>
